package edu.xmut.yuepaibackend.controller;

import edu.xmut.yuepaibackend.model.vo.BlogDetailVo;
import edu.xmut.yuepaibackend.model.vo.PageVO;
import edu.xmut.yuepaibackend.service.BlogService;
import edu.xmut.yuepaibackend.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private BlogService blogService;


    @GetMapping("/recommend/{pageNum}/{pageSize}")
    public R recommend(@PathVariable("pageNum")
                       Integer pageNum,
                       @PathVariable("pageSize")
                       Integer pageSize) {
        PageVO pageVO = blogService.recommend(pageNum, pageSize);
        return R.ok(pageVO);
    }

    @GetMapping("/details/{id}")
    public R getBlogDetail(@PathVariable("id")
                           Long id) {
        BlogDetailVo blogDetailVo = blogService.getBlogDetail(id);
        return R.ok(blogDetailVo);
    }


}
